<?php
// +----------------------------------------------------------------------
// | ZGUAN [ 致力于帮助更多的中小企业实现低成本数字化转型 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.zguan.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ZGUAN 并不是自由软件，未经许可不能去掉ZGUAN 相关版权
// +----------------------------------------------------------------------
// | Author: ZGUAN Team <admin@zguan.cn>  0769-82282996  15899929162
// +----------------------------------------------------------------------
namespace app\validate\property\users;

use think\Validate;

class PropertyUsersValidate extends Validate
{
    protected $rule = [
        'account|登录账号' => 'require',
        'mobile|手机号' => 'require',
        'username|姓名' => 'require',
        'password|登录密码' => 'require',
    ];

    public function sceneAdd()
    {
        return $this->remove('id', 'require');
    }

    public function sceneEdit()
    {
        return $this->remove('id', 'require')->remove('password', 'require');
    }

    public function sceneDel()
    {
        return $this->only(['id'])->append('id', 'require|number');
    }

    public function sceneSelfEdit()
    {
        return $this->only(['mobile', 'email', 'username'])
            ->append('username', 'require')
            ->append('email', 'require')
            ->append('mobile', 'require');
    }

    public function sceneEditPassword()
    {
        return $this->only(['password', 'old_password', 're_password'])
            ->append('old_password', 'require')
            ->append('re_password', 'require|confirm:password');
    }
}